package com.stt.design.controller;

import com.stt.design.mediator.DeviceMediator;
import com.stt.design.voice.VoiceCommand;
import com.stt.design.voice.VoiceCommandProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 新版智能家居控制器
 */
@RestController
@RequestMapping("/api/smart/v2")
public class NewSmartHomeController {
    
    @Autowired
    private DeviceMediator deviceMediator;
    
    @Autowired
    private VoiceCommandProcessor voiceCommandProcessor;
    
    /**
     * 执行场景
     */
    @PostMapping("/scenes/{sceneName}")
    public void executeScene(@PathVariable String sceneName) {
        deviceMediator.executeScene(sceneName);
    }
    
    /**
     * 获取操作历史
     */
    @GetMapping("/history")
    public List<String> getCommandHistory() {
        return deviceMediator.getCommandHistory();
    }
    
    /**
     * 处理语音命令
     */
    @PostMapping("/voice")
    public void processVoiceCommand(@RequestBody VoiceCommand command) {
        voiceCommandProcessor.processCommand(command);
    }
    
    /**
     * 撤销上一个操作
     */
    @PostMapping("/undo")
    public void undoLastCommand() {
        deviceMediator.undoLastCommand();
    }
} 